/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 *
 * @author eneko
 */

package rmi;

//import aso.upna.cancion.CancionRemota;
//import aso.upna.cancion.Metadata;
import java.io.*;
import java.rmi.*;
import java.rmi.server.*;
import java.io.Serializable;
import java.util.Vector;
import java.util.logging.Level;
import java.util.logging.Logger;

public class Imple extends UnicastRemoteObject implements Inter{
    public Imple() throws RemoteException{
        super();
    }


    /**
     * Método que  crea la estructura de directorios del almacén de metadatos, si no existe ya.
     */

    public String CreaDirectorios(String ruta) throws RemoteException{
        //String ruta = new String("./Metadatos/"+artista+"/Letras/");
        //File f = new File("./Metadatos/" + artista + "/Letras/");
        File f = new File(ruta);
        if (f.exists()){

        }
        else{
            f.mkdirs();
        }
        return ruta;
    }

    public Vector read(File v) throws RemoteException {
        FileReader fr;
        String linea,video;
        Vector ve = new Vector();
        try {
            fr = new FileReader(v);
            BufferedReader bfr=new BufferedReader(fr);

            while((linea=bfr.readLine())!=null){
                video=linea;
                ve.add(linea);
            }

            return ve;

        } catch (Exception ex) {
            Logger.getLogger(Imple.class.getName()).log(Level.SEVERE, null, ex);
            return null;
        }
    }

    public void CreaFichero(String ruta) throws RemoteException{
        new File(ruta);
    }

    public void write(String filename,String msg) throws RemoteException{
        FileWriter fw=null;
        try {
            fw = new FileWriter(filename, true);
            fw.write(msg);
            fw.flush();
            fw.close();
        } catch (IOException ex) {
            Logger.getLogger(ProcessFile.class.getName()).log(Level.SEVERE, null, ex);
        }
    }
}